package com.coda.service.impl;

import com.coda.entity.Unit;
import com.coda.mapper.UnitMapper;
import com.coda.service.UnitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@CacheConfig(cacheNames = "unitCache")
@Service
public class UnitServiceImpl implements UnitService {

    @Autowired
    private UnitMapper unitMapper;

    /**
     * 查询所有单位
     * @return
     */
    @Cacheable(key = "'all:unit'")
    @Override
    public List<Unit> getUnitList() {
        List<Unit> unitList = unitMapper.getUnitList();
        return unitList;
    }
}
